#ifndef LIGHT_H
#define LIGHT_H

#include "Colour.h"
#include "Vec3.h"

class Light 
{
public:
	Light();
	~Light();

	void SetType(int type)
	{m_Type = type;}
	int GetType() {return m_Type;}

	/* Ambient colour of light */
	void SetAmbient(const Colour &colour)
	{m_Ambient = colour;}
	const Colour GetAmbient() { return m_Ambient; }

	/* Diffuse colour of light */
	void SetDiffuse(const Colour &colour)
	{m_Diffuse = colour;}
	const Colour GetDiffuse() { return m_Diffuse; }

	/* Specular colour of light */
	void SetSpecular(const Colour &colour)
	{m_Specular = colour;}
	const Colour GetSpecular() {return m_Specular; }

	/* Direction in world space */
	void SetDirection(const Vec3 &Direction)
	{m_Direction = Direction;}
	const Vec3 GetDirection() { return m_Direction; }

	/* Position in world space */
	void SetPosition(const Vec3 &Position)
	{m_Position = Position;}
	const Vec3 GetPosition() { return m_Position; }

	/* Cutoff range */
	void SetRange(float range)
	{m_Range = range;}
	float GetRange() { return m_Range; }

	//Attenuation (how the light level decreases over distance) and a range
	/* Constant attenuation */
	void SetAttenuation0(float Atten){ m_Attenuation0 = Atten; }
	float GetAttenuation0() { return m_Attenuation0; }
	/* Linear attenuation */
	void SetAttenuation1(float Atten){ m_Attenuation1 = Atten; }
	float GetAttenuation1() { return m_Attenuation1; }
	/* Quadratic attenuation */
	void SetAttenuation2(float Atten){ m_Attenuation2 = Atten; }
	float GetAttenuation2() { return m_Attenuation2; }

	//Falloff defines the decrease in illumination between 
	//the outside of the inner cone and the outside of the outer cone
	/* Falloff */
	void SetFallOff(float falloff) { m_Falloff = falloff; }
	float GetFalloff() { return m_Falloff; } 

	/* Inner angle of spotlight cone */
	void SetTheta(float theta) { m_Theta = theta; }
	float GetTheta() { return m_Theta; } 

	/* Outer angle of spotlight cone */  
	void SetPhi(float phi) { m_Phi = phi; }
	float GetPhi() { return m_Phi; } 

	void Init(int type, const Colour &colour, const Vec3 &Direction, const Vec3 &Position);

	void SetAlpha(const float alpha);
	bool HasAlpha() const { return GetAlpha() != fOPAQUE; }
	float GetAlpha() const { return m_Diffuse.a; }

	void Use();
	void Set();
	void Enable();
	void Disable();

	bool IsOn() {return m_IsOn;}

	void Draw();

private:
	void SetID();

private:

	//1 = Dir 2 = Point 3 = Spot
	int m_Type;

	unsigned int m_ID;
	bool m_IsOn;

	Colour m_Ambient;
	Colour m_Diffuse;
	Colour m_Specular;

	Vec3 m_Direction;
	Vec3 m_Position;

	/* Cutoff range */
	float m_Range;

	//Attenuation (how the light level decreases over distance) and a range
	/* Constant attenuation */
	float m_Attenuation0;
	/* Linear attenuation */
	float m_Attenuation1;
	/* Quadratic attenuation */
	float m_Attenuation2;

	//Falloff defines the decrease in illumination between 
	//the outside of the inner cone and the outside of the outer cone
	/* Falloff */
	float m_Falloff;

	/* Inner angle of spotlight cone */
	float m_Theta;

	/* Outer angle of spotlight cone */  
	float m_Phi;

};

#endif